 
// Source File Name:   InternalConvenienceMethods.java

package com.sunwayhorizo.health.hl7.datatypes.common;

import com.sunwayhorizo.health.hl7.common.Hl7Exception;
import com.sunwayhorizo.health.hl7.common.VersionInfo;
import com.sunwayhorizo.health.hl7.datatypes.AD;
import com.sunwayhorizo.health.hl7.datatypes.ADXP;
import com.sunwayhorizo.health.hl7.datatypes.BAG_AD;
import com.sunwayhorizo.health.hl7.datatypes.BAG_EN;
import com.sunwayhorizo.health.hl7.datatypes.BAG_TEL;
import com.sunwayhorizo.health.hl7.datatypes.BIN;
import com.sunwayhorizo.health.hl7.datatypes.BL;
import com.sunwayhorizo.health.hl7.datatypes.BN;
import com.sunwayhorizo.health.hl7.datatypes.CD;
import com.sunwayhorizo.health.hl7.datatypes.CE;
import com.sunwayhorizo.health.hl7.datatypes.CS;
import com.sunwayhorizo.health.hl7.datatypes.CV;
import com.sunwayhorizo.health.hl7.datatypes.ED;
import com.sunwayhorizo.health.hl7.datatypes.EIVL;
import com.sunwayhorizo.health.hl7.datatypes.EN;
import com.sunwayhorizo.health.hl7.datatypes.ENXP;
import com.sunwayhorizo.health.hl7.datatypes.GTS;
import com.sunwayhorizo.health.hl7.datatypes.II;
import com.sunwayhorizo.health.hl7.datatypes.INT;
import com.sunwayhorizo.health.hl7.datatypes.IVL_INT;
import com.sunwayhorizo.health.hl7.datatypes.IVL_MO;
import com.sunwayhorizo.health.hl7.datatypes.IVL_PQ;
import com.sunwayhorizo.health.hl7.datatypes.IVL_REAL;
import com.sunwayhorizo.health.hl7.datatypes.IVL_RTO_PQ;
import com.sunwayhorizo.health.hl7.datatypes.IVL_TS;
import com.sunwayhorizo.health.hl7.datatypes.LIST_ADXP;
import com.sunwayhorizo.health.hl7.datatypes.LIST_ENXP;
import com.sunwayhorizo.health.hl7.datatypes.LIST_INT;
import com.sunwayhorizo.health.hl7.datatypes.MO;
import com.sunwayhorizo.health.hl7.datatypes.OID;
import com.sunwayhorizo.health.hl7.datatypes.ON;
import com.sunwayhorizo.health.hl7.datatypes.PIVL;
import com.sunwayhorizo.health.hl7.datatypes.PN;
import com.sunwayhorizo.health.hl7.datatypes.PQ;
import com.sunwayhorizo.health.hl7.datatypes.REAL;
import com.sunwayhorizo.health.hl7.datatypes.RTO_INT;
import com.sunwayhorizo.health.hl7.datatypes.RTO_MO_PQ;
import com.sunwayhorizo.health.hl7.datatypes.RTO_PQ;
import com.sunwayhorizo.health.hl7.datatypes.SC;
import com.sunwayhorizo.health.hl7.datatypes.SET_CD;
import com.sunwayhorizo.health.hl7.datatypes.SET_CE;
import com.sunwayhorizo.health.hl7.datatypes.SET_CS;
import com.sunwayhorizo.health.hl7.datatypes.SET_II;
import com.sunwayhorizo.health.hl7.datatypes.SET_INT;
import com.sunwayhorizo.health.hl7.datatypes.SET_PQ;
import com.sunwayhorizo.health.hl7.datatypes.SET_RTO_PQ;
import com.sunwayhorizo.health.hl7.datatypes.ST;
import com.sunwayhorizo.health.hl7.datatypes.TEL;
import com.sunwayhorizo.health.hl7.datatypes.TN;
import com.sunwayhorizo.health.hl7.datatypes.TS;
import com.sunwayhorizo.health.hl7.datatypes.UID;
import com.sunwayhorizo.health.hl7.datatypes.URL;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Date;


//            ADImpl, ADXPImpl, BAG_ADImpl, BAG_ENImpl,
//            BAG_TELImpl, BINImpl, BLImpl, BNImpl, 
//            CDImpl, CEImpl, CSImpl, CVImpl, 
//            EDImpl, EIVLImpl, ENImpl, ENXPImpl, 
//            GTSHullImpl, GTSNullImpl, IIImpl, INTImpl, 
//            IVL_INTImpl, IVL_MOImpl, IVL_PQImpl, IVL_REALImpl, 
//            IVL_RTO_PQImpl, IVL_TSImpl, LIST_ADXPAdapterImpl, LIST_ENXPAdapterImpl, 
//            LIST_INTAdapterImpl, MOImpl, NullFlavorImpl, OIDImpl, 
//            ONImpl, PIVL_TSImpl, PNImpl, PQImpl, 
//            REALBigDecimalImpl, REALImpl, RTO_INTImpl, RTO_MO_PQImpl, 
//            RTO_PQImpl, SCImpl, SET_CDImpl, SET_CEImpl, 
//            SET_CSImpl, SET_IIImpl, SET_INTImpl, SET_PQImpl, 
//            SET_RTO_PQImpl, STImpl, TELImpl, TNImpl, 
//            TSImpl, UIDImpl, URLImpl

public class InternalConvenienceMethods
{

    public static final String RCS_ID = "$Header: InternalConvenienceMethods.java 1.0 2006/05/15 11:35:41 atomlins noship $";
    public static final boolean RCS_ID_RECORDED = VersionInfo.recordClassVersion("$Header: InternalConvenienceMethods.java 1.0 2006/05/15 11:35:41 atomlins noship $", "com.sunwayhorizo.health.hl7.datatypes.common");

    public InternalConvenienceMethods()
    {
    }

    public BL newBL(boolean flag)
    {
        return BLImpl.valueOf(flag);
    }

    public BL newBL(String s)
    {
        return BLImpl.valueOf(s);
    }

    public BL nullBL(CS cs)
    {
        return BLImpl.nullBL(cs);
    }

    public BN newBN(boolean flag)
    {
        return BNImpl.valueOf(flag);
    }

    public ED newED(String s, CS cs, CS cs1, CS cs2, CS cs3, TEL tel, BIN bin, 
            CS cs4, ED ed, CS cs5)
    {
        return EDImpl.valueOf(s, checkNull(cs), checkNull(cs1), checkNull(cs2), checkNull(cs3), checkNull(tel), checkNull(bin), checkNull(cs4), checkNull(ed), checkNull(cs5));
    }

    public ED nullED(CS cs)
    {
        return EDImpl.nullED(cs);
    }

    public ST newST(String s)
    {
        if(s == null)
            return nullST(NullFlavorImpl.NI);
        else
            return STImpl.valueOf(s);
    }

    public ST newST(char c)
    {
        return STImpl.valueOf(c);
    }

    public ST newST(String s, CS cs)
    {
        if(s == null)
            return nullST(NullFlavorImpl.NI);
        else
            return STImpl.valueOf(s, checkNull(cs));
    }

    public ST nullST(CS cs)
    {
        return STImpl.nullST(cs);
    }
   //2012 10 23 注释
//    public CD newCD(String s, String s1)
//    {
//        return CDImpl.valueOf(s, s1);
//    }

    public CD nullCD(CS cs)
    {
        return CDImpl.nullCD(cs);
    }

    public CS newCS(String s)
    {
        if(s == null)
            return nullCS(NullFlavorImpl.NI);
        else
            return CSImpl.valueOf(s);
    }

    public CS nullCS(CS cs)
    {
        return CSImpl.nullCS(cs);
    }
    //2012 10 23 注释

//    public CV newCV(String s, String s1)
//    {
//        return (CV)CVImpl.valueOf(s, s1);
//    }

    public CV nullCV(CS cs)
    {
        return CVImpl.nullCV(cs);
    }
     //2012 10 23 注释

//    public CE newCE(String s, String s1)
//    {
//        return (CE)CEImpl.valueOf(s, s1);
//    }
   //2012 10 23 注释

//    public CE nullCE(CS cs)
//    {
//        return CEImpl.nullCE(cs);
//    }
 //2012 10 23 注释
//    public SC newSC(String s, CE ce)
//    {
//        return SCImpl.valueOf(s, checkNull(ce));
//    }

    public SC newSC(String s)
    {
        if(s == null)
            return nullSC(NullFlavorImpl.NI);
        else
            return SCImpl.valueOf(s);
    }

    public SC nullSC(CS cs)
    {
        return SCImpl.nullSC(cs);
    }

    public UID newUID(String s)
    {
        if(s == null)
            return nullUID(NullFlavorImpl.NI);
        else
            return UIDImpl.valueOf(s);
    }

    public UID nullUID(CS cs)
    {
        return UIDImpl.nullUID(cs);
    }

    public II newII(UID uid, ST st, ST st1)
    {
        return IIImpl.valueOf(uid, checkNull(st), checkNull(st1));
    }

    public II nullII(CS cs)
    {
        return IIImpl.nullII(cs);
    }

    public URL newURL(CS cs, ST st)
    {
        return URLImpl.valueOf(checkNull(cs), checkNull(st));
    }

    public URL newURL(String s, String s1)
    {
        if(s == null || s1 == null)
            return nullURL(NullFlavorImpl.NI);
        else
            return URLImpl.valueOf(s, s1);
    }

    public URL nullURL(CS cs)
    {
        return URLImpl.nullURL(cs);
    }

    public TEL newTEL(CS cs, ST st, GTS gts, SET_CS set_cs)
    {
        return TELImpl.valueOf(checkNull(cs), checkNull(st), checkNull(gts), checkNull(set_cs));
    }

    public TEL newTEL(String s, String s1, GTS gts, SET_CS set_cs)
    {
        if(s == null || s1 == null)
            return nullTEL(NullFlavorImpl.NI);
        else
            return TELImpl.valueOf(s, s1, checkNull(gts), checkNull(set_cs));
    }

    public TEL nullTEL(CS cs)
    {
        return TELImpl.nullTEL(cs);
    }

    public ADXP newADXP(String s, CS cs)
    {
        if(s == null)
            return nullADXP(NullFlavorImpl.NI);
        else
            return ADXPImpl.valueOf(s, checkNull(cs));
    }

    public ADXP nullADXP(CS cs)
    {
        return ADXPImpl.nullADXP(cs);
    }

    public AD nullAD(CS cs)
    {
        return ADImpl.nullAD(cs);
    }

    public AD newAD(ADXP aadxp[], SET_CS set_cs, GTS gts, BL bl)
    {
        java.util.List list = Arrays.asList(aadxp);
        return ADImpl.valueOf(list, checkNull(set_cs), checkNull(gts), checkNull(bl));
    }

    public AD newAD(ADXP aadxp[], SET_CS set_cs, GTS gts, ST st)
    {
        return ADImpl.valueOf(aadxp, checkNull(set_cs), checkNull(gts), st);
    }

    public ENXP newENXP(String s, CS cs, SET_CS set_cs)
    {
        if(s == null)
            return nullENXP(NullFlavorImpl.NI);
        else
            return ENXPImpl.valueOf(s, checkNull(cs), checkNull(set_cs));
    }

    public ENXP nullENXP(CS cs)
    {
        return ENXPImpl.nullENXP(cs);
    }

    public EN nullEN(CS cs)
    {
        return ENImpl.nullEN(cs);
    }

    public EN newEN(ENXP aenxp[], SET_CS set_cs, IVL_TS ivl_ts)
    {
        return ENImpl.valueOf(aenxp, checkNull(set_cs), checkNull(ivl_ts));
    }

    public ON nullON(CS cs)
    {
        return ONImpl.nullON(cs);
    }

    public ON newON(ENXP aenxp[], SET_CS set_cs, IVL_TS ivl_ts)
    {
        return ONImpl.valueOf(aenxp, checkNull(set_cs), checkNull(ivl_ts));
    }

    public PN nullPN(CS cs)
    {
        return PNImpl.nullPN(cs);
    }

    public PN newPN(ENXP aenxp[], SET_CS set_cs, IVL_TS ivl_ts)
    {
        return PNImpl.valueOf(aenxp, checkNull(set_cs), checkNull(ivl_ts));
    }

    public TN newTN(String s)
    {
        if(s == null)
            return nullTN(NullFlavorImpl.NI);
        else
            return TNImpl.valueOf(s);
    }

    public TN nullTN(CS cs)
    {
        return TNImpl.nullTN(cs);
    }

    public INT newINT(long l)
    {
        return INTImpl.valueOf(l);
    }

    public INT nullINT(CS cs)
    {
        return INTImpl.nullINT(cs);
    }

    public REAL newREAL(String s)
    {
        if(s == null)
            return nullREAL(NullFlavorImpl.NI);
        else
            return REALImpl.valueOf(s);
    }

    public REAL newREAL(BigDecimal bigdecimal)
    {
        if(bigdecimal == null)
            return nullREAL(NullFlavorImpl.NI);
        else
            return REALBigDecimalImpl.valueOf(bigdecimal);
    }

    public REAL nullREAL(CS cs)
    {
        return REALImpl.nullREAL(cs);
    }

    public RTO_PQ newRTO_PQ()
    {
        return RTO_PQImpl.valueOf();
    }

    public RTO_PQ newRTO_PQ(PQ pq, PQ pq1)
    {
        return RTO_PQImpl.valueOf(checkNull(pq), checkNull(pq1));
    }

    public RTO_PQ nullRTO_PQ(CS cs)
    {
        return RTO_PQImpl.nullRTO_PQ(cs);
    }

    public RTO_INT newRTO_INT()
    {
        return RTO_INTImpl.valueOf();
    }

    public RTO_INT newRTO_INT(INT int1, INT int2)
    {
        return RTO_INTImpl.valueOf(checkNull(int1), checkNull(int2));
    }

    public RTO_INT nullRTO_INT(CS cs)
    {
        return RTO_INTImpl.nullRTO_INT(cs);
    }

    public PQ newPQ(REAL real, CS cs)
    {
        return PQImpl.valueOf(checkNull(real), checkNull(cs));
    }

    public PQ newPQ(String s, String s1)
    {
        if(s == null || s1 == null)
            return nullPQ(NullFlavorImpl.NI);
        else
            return PQImpl.valueOf(s, s1);
    }

    public PQ nullPQ(CS cs)
    {
        return PQImpl.nullPQ(cs);
    }

    public MO newMO(REAL real, CS cs)
    {
        return MOImpl.valueOf(checkNull(real), checkNull(cs));
    }

    public MO nullMO(CS cs)
    {
        return MOImpl.nullMO(cs);
    }

    public SET_II nullSET_II(CS cs)
    {
        return SET_IIImpl.nullSET_II(cs);
    }

    public SET_II newSET_II(II aii[])
    {
        if(aii == null)
            return nullSET_II(NullFlavorImpl.NI);
        else
            return SET_IIImpl.valueOf(aii);
    }

    public SET_II newSET_II(II ii)
    {
        if(ii == null || ii.isNull().isTrue())
            return nullSET_II(NullFlavorImpl.NI);
        else
            return SET_IIImpl.valueOf(ii);
    }

    public SET_CD nullSET_CD(CS cs)
    {
        return SET_CDImpl.nullSET_CD(cs);
    }

    public SET_CD newSET_CD(CD acd[])
    {
        if(acd == null)
            return nullSET_CD(NullFlavorImpl.NI);
        else
            return SET_CDImpl.valueOf(acd);
    }

    public SET_CD newSET_CD(CD cd)
    {
        if(cd == null || cd.isNull().isTrue())
            return nullSET_CD(NullFlavorImpl.NI);
        else
            return SET_CDImpl.valueOf(cd);
    }

    public SET_CS nullSET_CS(CS cs)
    {
        return SET_CSImpl.nullSET_CS(cs);
    }

    public SET_CS newSET_CS(CS acs[])
    {
        if(acs == null || acs.length == 0)
            return nullSET_CS(NullFlavorImpl.NI);
        else
            return SET_CSImpl.valueOf(acs);
    }

    public SET_CS newSET_CS(CS cs)
    {
        if(cs == null || cs.isNull().isTrue())
            return nullSET_CS(NullFlavorImpl.NI);
        else
            return SET_CSImpl.valueOf(cs);
    }

    public SET_CE newSET_CE(CE ace[])
    {
        if(ace == null || ace.length == 0)
            return nullSET_CE(NullFlavorImpl.NI);
        else
            return SET_CEImpl.valueOf(ace);
    }

    public SET_CE newSET_CE(CE ce)
    {
        if(ce == null || ce.isNull().isTrue())
            return nullSET_CE(NullFlavorImpl.NI);
        else
            return SET_CEImpl.valueOf(ce);
    }

    public SET_CE nullSET_CE(CS cs)
    {
        return SET_CEImpl.nullSET_CE(cs);
    }

    public SET_INT nullSET_INT(CS cs)
    {
        return SET_INTImpl.nullSET_INT(cs);
    }

    public SET_INT newSET_INT(INT aint[])
    {
        if(aint == null || aint.length == 0)
            return nullSET_INT(NullFlavorImpl.NI);
        else
            return SET_INTImpl.valueOf(aint);
    }

    public SET_INT newSET_INT(INT int1)
    {
        if(int1 == null || int1.isNull().isTrue())
            return nullSET_INT(NullFlavorImpl.NI);
        else
            return SET_INTImpl.valueOf(int1);
    }

    public SET_PQ nullSET_PQ(CS cs)
    {
        return SET_PQImpl.nullSET_PQ(cs);
    }

    public SET_PQ newSET_PQ(PQ apq[])
    {
        if(apq == null || apq.length == 0)
            return nullSET_PQ(NullFlavorImpl.NI);
        else
            return SET_PQImpl.valueOf(apq);
    }

    public SET_PQ newSET_PQ(PQ pq)
    {
        if(pq == null || pq.isNull().isTrue())
            return nullSET_PQ(NullFlavorImpl.NI);
        else
            return SET_PQImpl.valueOf(pq);
    }

    public SET_RTO_PQ nullSET_RTO_PQ(CS cs)
    {
        return SET_RTO_PQImpl.nullSET_RTO_PQ(cs);
    }

    public SET_RTO_PQ newSET_RTO_PQ(RTO_PQ arto_pq[])
    {
        if(arto_pq == null || arto_pq.length == 0)
            return nullSET_RTO_PQ(NullFlavorImpl.NI);
        else
            return SET_RTO_PQImpl.valueOf(arto_pq);
    }

    public SET_RTO_PQ newSET_RTO_PQ(RTO_PQ rto_pq)
    {
        if(rto_pq == null || rto_pq.isNull().isTrue())
            return nullSET_RTO_PQ(NullFlavorImpl.NI);
        else
            return SET_RTO_PQImpl.valueOf(rto_pq);
    }

    public LIST_INT nullLIST_INT(CS cs)
    {
        return LIST_INTAdapterImpl.nullLIST_INT(cs);
    }

    public LIST_INT newLIST_INT(INT aint[])
    {
        if(aint == null || aint.length == 0)
            return nullLIST_INT(NullFlavorImpl.NI);
        else
            return LIST_INTAdapterImpl.valueOf(aint);
    }

    public LIST_INT newLIST_INT(INT int1)
    {
        if(int1 == null || int1.isNull().isTrue())
            return nullLIST_INT(NullFlavorImpl.NI);
        else
            return LIST_INTAdapterImpl.valueOf(int1);
    }

    public LIST_ENXP nullLIST_ENXP(CS cs)
    {
        return LIST_ENXPAdapterImpl.nullLIST_ENXP(cs);
    }

    public LIST_ENXP newLIST_ENXP(ENXP aenxp[])
    {
        if(aenxp == null || aenxp.length == 0)
            return nullLIST_ENXP(NullFlavorImpl.NI);
        else
            return LIST_ENXPAdapterImpl.valueOf(aenxp);
    }

    public LIST_ENXP newLIST_ENXP(ENXP enxp)
    {
        if(enxp == null || enxp.isNull().isTrue())
            return nullLIST_ENXP(NullFlavorImpl.NI);
        else
            return LIST_ENXPAdapterImpl.valueOf(enxp);
    }

    public LIST_ADXP nullLIST_ADXP(CS cs)
    {
        return LIST_ADXPAdapterImpl.nullLIST_ADXP(cs);
    }

    public LIST_ADXP newLIST_ADXP(ADXP aadxp[])
    {
        if(aadxp == null || aadxp.length == 0)
            return nullLIST_ADXP(NullFlavorImpl.NI);
        else
            return LIST_ADXPAdapterImpl.valueOf(aadxp);
    }

    public LIST_ADXP newLIST_ADXP(ADXP adxp)
    {
        if(adxp == null || adxp.isNull().isTrue())
            return nullLIST_ADXP(NullFlavorImpl.NI);
        else
            return LIST_ADXPAdapterImpl.valueOf(adxp);
    }

    public BAG_TEL nullBAG_TEL(CS cs)
    {
        return BAG_TELImpl.nullBAG_TEL(cs);
    }

    public BAG_TEL newBAG_TEL(TEL atel[])
    {
        if(atel == null || atel.length == 0)
            return nullBAG_TEL(NullFlavorImpl.NI);
        else
            return BAG_TELImpl.valueOf(atel);
    }

    public BAG_TEL newBAG_TEL(TEL tel)
    {
        if(tel == null || tel.isNull().isTrue())
            return nullBAG_TEL(NullFlavorImpl.NI);
        else
            return BAG_TELImpl.valueOf(tel);
    }

    public BAG_EN nullBAG_EN(CS cs)
    {
        return BAG_ENImpl.nullBAG_EN(cs);
    }

    public BAG_EN newBAG_EN(EN aen[])
    {
        if(aen == null || aen.length == 0)
            return nullBAG_EN(NullFlavorImpl.NI);
        else
            return BAG_ENImpl.valueOf(aen);
    }

    public BAG_EN newBAG_EN(EN en)
    {
        if(en == null || en.isNull().isTrue())
            return nullBAG_EN(NullFlavorImpl.NI);
        else
            return BAG_ENImpl.valueOf(en);
    }

    public BAG_AD nullBAG_AD(CS cs)
    {
        return BAG_ADImpl.nullBAG_AD(cs);
    }

    public BAG_AD newBAG_AD(AD aad[])
    {
        if(aad == null || aad.length == 0)
            return nullBAG_AD(NullFlavorImpl.NI);
        else
            return BAG_ADImpl.valueOf(aad);
    }

    public BAG_AD newBAG_AD(AD ad)
    {
        if(ad == null || ad.isNull().isTrue())
            return nullBAG_AD(NullFlavorImpl.NI);
        else
            return BAG_ADImpl.valueOf(ad);
    }

    public IVL_INT newIVL_INT(INT int1, BL bl, INT int2, BL bl1)
        throws Hl7Exception
    {
        return IVL_INTImpl.valueOf(checkNull(int1), checkNull(bl), checkNull(int2), checkNull(bl1));
    }

    public IVL_INT newIVL_INT(INT int1)
    {
        if(int1 == null || int1.isNull().isTrue())
            return nullIVL_INT(NullFlavorImpl.NI);
        else
            return IVL_INTImpl.valueOf(int1, BLImpl.TRUE, int1, BLImpl.TRUE);
    }

    public IVL_INT nullIVL_INT(CS cs)
    {
        return IVL_INTImpl.nullIVL_INT(cs);
    }

    public IVL_TS newIVL_TS(String s)
        throws Hl7Exception
    {
        if(s == null)
            return nullIVL_TS(NullFlavorImpl.NI);
        else
            return IVL_TSImpl.valueOf(s);
    }

    public IVL_TS newIVL_TS(TS ts)
    {
        if(ts == null || ts.isNull().isTrue())
            return nullIVL_TS(NullFlavorImpl.NI);
        else
            return IVL_TSImpl.valueOf(ts);
    }

    public IVL_TS newIVL_TS(TS ts, BL bl, TS ts1, BL bl1)
        throws Hl7Exception
    {
        return IVL_TSImpl.valueOf(checkNull(ts), checkNull(bl), checkNull(ts1), checkNull(bl1));
    }

    public IVL_TS nullIVL_TS(CS cs)
    {
        return IVL_TSImpl.nullIVL_TS(cs);
    }

    public IVL_PQ newIVL_PQ(REAL real, BL bl, REAL real1, BL bl1, CS cs)
    {
        return IVL_PQImpl.valueOf(checkNull(real), checkNull(bl), checkNull(real1), checkNull(bl1), checkNull(cs));
    }

    public IVL_PQ newIVL_PQ(PQ pq, BL bl, PQ pq1, BL bl1)
    {
        return IVL_PQImpl.valueOf(checkNull(pq), checkNull(bl), checkNull(pq1), checkNull(bl1));
    }

    public IVL_PQ nullIVL_PQ(CS cs)
    {
        return IVL_PQImpl.nullIVL_PQ(cs);
    }

    public IVL_PQ newIVL_PQ(PQ pq)
    {
        if(pq == null || pq.isNull().isTrue())
            return nullIVL_PQ(NullFlavorImpl.NI);
        else
            return IVL_PQImpl.valueOf(pq, BLImpl.TRUE, pq, BLImpl.TRUE);
    }

    public TS newTS(Date date, INT int1, PQ pq)
    {
        return TSImpl.valueOf(date, checkNull(int1), checkNull(pq));
    }

    public TS newTS(Date date, INT int1)
    {
        return TSImpl.valueOf(date, checkNull(int1));
    }

    public TS newTS(Date date)
    {
        if(date == null)
            return nullTS(NullFlavorImpl.NI);
        else
            return TSImpl.valueOf(date);
    }

    public TS newTS(String s)
        throws Hl7Exception
    {
        if(s == null)
            return nullTS(NullFlavorImpl.NI);
        else
            return TSImpl.valueOf(s);
    }

    public TS nullTS(CS cs)
    {
        return TSImpl.nullTS(cs);
    }

    public PIVL newPIVL(String s)
        throws Hl7Exception
    {
        if(s == null)
            return nullPIVL(NullFlavorImpl.NI);
        else
            return PIVL_TSImpl.valueOf(s);
    }

    public PIVL newPIVL(IVL_TS ivl_ts, PQ pq, CS cs, BL bl)
    {
        return PIVL_TSImpl.valueOf(checkNull(ivl_ts), checkNull(pq), checkNull(cs), checkNull(bl));
    }

    public PIVL nullPIVL(CS cs)
    {
        return PIVL_TSImpl.nullPIVL_TS(cs);
    }

    public EIVL newEIVL(String s)
        throws Hl7Exception
    {
        if(s == null)
            return nullEIVL(NullFlavorImpl.NI);
        else
            return EIVLImpl.valueOf(s);
    }

    public EIVL newEIVL(CS cs, IVL_PQ ivl_pq)
    {
        return EIVLImpl.valueOf(checkNull(cs), checkNull(ivl_pq));
    }

    public EIVL nullEIVL(CS cs)
    {
        return EIVLImpl.nullEIVL(cs);
    }

    public GTS newGTS(String s)
        throws Hl7Exception
    {
        if(s == null)
            return nullGTS(NullFlavorImpl.NI);
        else
            return GTSHullImpl.valueOf(s);
    }

    public GTS newGTS(TS ts)
        throws Hl7Exception
    {
        if(ts == null || ts.isNull().isTrue())
        {
            return nullGTS(NullFlavorImpl.NI);
        } else
        {
            IVL_TS ivl_ts = newIVL_TS(ts);
            return newGTS(ivl_ts);
        }
    }

    public GTS newGTS(IVL_TS ivl_ts)
    {
        if(ivl_ts == null || ivl_ts.isNull().isTrue())
            return nullGTS(NullFlavorImpl.NI);
        else
            return GTSHullImpl.valueOf(ivl_ts);
    }

    public GTS nullGTS(CS cs)
    {
        return GTSNullImpl.nullGTS(cs);
    }

    public OID newOID(String s)
    {
        if(s == null)
            return nullOID(NullFlavorImpl.NI);
        else
            return OIDImpl.valueOf(s);
    }

    public OID nullOID(CS cs)
    {
        return OIDImpl.nullOID(cs);
    }

    public IVL_MO newIVL_MO(MO mo, BL bl, MO mo1, BL bl1)
    {
        return IVL_MOImpl.valueOf(checkNull(mo), checkNull(bl), checkNull(mo1), checkNull(bl1));
    }

    public IVL_MO newIVL_MO(REAL real, BL bl, REAL real1, BL bl1, CS cs)
    {
        return IVL_MOImpl.valueOf(checkNull(real), checkNull(bl), checkNull(real1), checkNull(bl1), checkNull(cs));
    }

    public IVL_MO newIVL_MO(MO mo)
    {
        if(mo == null || mo.isNull().isTrue())
            return nullIVL_MO(NullFlavorImpl.NI);
        else
            return IVL_MOImpl.valueOf(mo, BLImpl.TRUE, mo, BLImpl.TRUE);
    }

    public IVL_MO nullIVL_MO(CS cs)
    {
        return IVL_MOImpl.nullIVL_MO(cs);
    }

    public IVL_REAL newIVL_REAL(REAL real, BL bl, REAL real1, BL bl1)
    {
        return IVL_REALImpl.valueOf(checkNull(real), checkNull(bl), checkNull(real1), checkNull(bl1));
    }

    public IVL_REAL newIVL_REAL(REAL real)
    {
        if(real == null || real.isNull().isTrue())
            return IVL_REALImpl.nullIVL_REAL(NullFlavorImpl.NI);
        else
            return IVL_REALImpl.valueOf(real, BLImpl.TRUE, real, BLImpl.TRUE);
    }

    public IVL_REAL nullIVL_REAL(CS cs)
    {
        return IVL_REALImpl.nullIVL_REAL(cs);
    }

    public IVL_RTO_PQ newIVL_RTO_PQ(RTO_PQ rto_pq, BL bl, RTO_PQ rto_pq1, BL bl1)
    {
        return IVL_RTO_PQImpl.valueOf(checkNull(rto_pq), checkNull(bl), checkNull(rto_pq1), checkNull(bl1));
    }

    public IVL_RTO_PQ newIVL_RTO_PQ(RTO_PQ rto_pq)
    {
        if(rto_pq == null || rto_pq.isNull().isTrue())
            return nullIVL_RTO_PQ(NullFlavorImpl.NI);
        else
            return IVL_RTO_PQImpl.valueOf(rto_pq, BLImpl.TRUE, rto_pq, BLImpl.TRUE);
    }

    public IVL_RTO_PQ nullIVL_RTO_PQ(CS cs)
    {
        return IVL_RTO_PQImpl.nullIVL_RTO_PQ(cs);
    }

    public RTO_MO_PQ newRTO_MO_PQ(MO mo, PQ pq)
    {
        return RTO_MO_PQImpl.valueOf(checkNull(mo), checkNull(pq));
    }

    public RTO_MO_PQ nullRTO_MO_PQ(CS cs)
    {
        return RTO_MO_PQImpl.nullRTO_MO_PQ(cs);
    }

    private static ED checkNull(ED ed)
    {
        if(ed == null)
            return EDImpl.nullED(NullFlavorImpl.NI);
        else
            return ed;
    }

    private static TEL checkNull(TEL tel)
    {
        if(tel == null)
            return TELImpl.nullTEL(NullFlavorImpl.NI);
        else
            return tel;
    }

    private static BIN checkNull(BIN bin)
    {
        if(bin == null)
            return BINImpl.nullBIN(NullFlavorImpl.NI);
        else
            return bin;
    }

    private static CS checkNull(CS cs)
    {
        if(cs == null)
            return CSImpl.nullCS(NullFlavorImpl.NI);
        else
            return cs;
    }
     //2012 10 23 注释

//    private static CE checkNull(CE ce)
//    {
//        if(ce == null)
//            return CEImpl.nullCE(NullFlavorImpl.NI);
//        else
//            return ce;
//    }

    private static UID checkNull(UID uid)
    {
        if(uid == null)
            return UIDImpl.nullUID(NullFlavorImpl.NI);
        else
            return uid;
    }

    private static ST checkNull(ST st)
    {
        if(st == null)
            return STImpl.nullST(NullFlavorImpl.NI);
        else
            return st;
    }

    private static BL checkNull(BL bl)
    {
        if(bl == null)
            return BLImpl.nullBL(NullFlavorImpl.NI);
        else
            return bl;
    }

    private static GTS checkNull(GTS gts)
    {
        if(gts == null)
            return GTSNullImpl.nullGTS(NullFlavorImpl.NI);
        else
            return gts;
    }

    private static SET_CS checkNull(SET_CS set_cs)
    {
        if(set_cs == null)
            return SET_CSImpl.nullSET_CS(NullFlavorImpl.NI);
        else
            return set_cs;
    }

    private static ADXP checkNull(ADXP adxp)
    {
        if(adxp == null)
            return ADXPImpl.nullADXP(NullFlavorImpl.NI);
        else
            return adxp;
    }

    private static ENXP checkNull(ENXP enxp)
    {
        if(enxp == null)
            return ENXPImpl.nullENXP(NullFlavorImpl.NI);
        else
            return enxp;
    }

    private static IVL_TS checkNull(IVL_TS ivl_ts)
    {
        if(ivl_ts == null)
            return IVL_TSImpl.nullIVL_TS(NullFlavorImpl.NI);
        else
            return ivl_ts;
    }

    private static PQ checkNull(PQ pq)
    {
        if(pq == null)
            return PQImpl.nullPQ(NullFlavorImpl.NI);
        else
            return pq;
    }

    private static INT checkNull(INT int1)
    {
        if(int1 == null)
            return INTImpl.nullINT(NullFlavorImpl.NI);
        else
            return int1;
    }

    private static TS checkNull(TS ts)
    {
        if(ts == null)
            return TSImpl.nullTS(NullFlavorImpl.NI);
        else
            return ts;
    }

    private static REAL checkNull(REAL real)
    {
        if(real == null)
            return REALImpl.nullREAL(NullFlavorImpl.NI);
        else
            return real;
    }

    private static IVL_PQ checkNull(IVL_PQ ivl_pq)
    {
        if(ivl_pq == null)
            return IVL_PQImpl.nullIVL_PQ(NullFlavorImpl.NI);
        else
            return ivl_pq;
    }

    private static MO checkNull(MO mo)
    {
        if(mo == null)
            return MOImpl.nullMO(NullFlavorImpl.NI);
        else
            return mo;
    }

    private static RTO_PQ checkNull(RTO_PQ rto_pq)
    {
        if(rto_pq == null)
            return RTO_PQImpl.nullRTO_PQ(NullFlavorImpl.NI);
        else
            return rto_pq;
    }

}
